import axios from './http.js'
import _ from 'lodash'

/**
 *
 * 主播信息，包括招募和运营
 */

// 获取主播列表
export function getActorList(config) {
  const url = '/mps/anchor/list'
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 获取线索主播列表
export function getClueActorList(config) {
  const url = '/mps/anchor/clue_list'
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}

// 获取合同主播列表
export function getAgreementActorList(config) {
  const url = '/bs/anchor/contract/list'
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}

// 增加主播
export function addActor(data, config) {
  const url = '/mps/anchor/save'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 修改主播资料
export function updateActor(data, config) {
  const url = '/mps/anchor/update'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 获取主播个人信息
export function getActorInfo(config) {
  const url = '/mps/anchor/view'
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 删除主播
export function deleteActor(data, config) {
  const url = '/mps/anchor/delete/' + data.anchorId

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}

// 更改主播签约意愿
export function changeActorWish(data, config) {
  const url = '/mps/anchor/update_signwish'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 更改主播签约状态
export function changeActorStatus(data, config) {
  const url = '/mps/anchor/update_status'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 获取主播跟进记录
export function getActorRecord(config) {
  const url = '/mps/anchor/followup/list/' + config.params.anchorId
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 新增主播跟进记录
export function addActorRecord(data, config) {
  const url = '/mps/anchor/followup/save'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 获取该主播签约记录
export function getAgentWish(config) {
  const url = '/mps/anchor/appraise/list/' + config.params.anchorId
  delete config.params.anchorId
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}

/* 运营 */

// 签约大厅
export function getHallList(config) {
  const url = '/mps/anchor/query_sign_hall'

  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 运营获取我的签约意愿
export function getOffer(config) {
  const url = '/mps/anchor/getSignIntention'

  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 添加运营报价
export function addOffer(data, config) {
  let url = '/mps/signIntention/'

  data = data || {}
  url += data.signIntention
  delete data.signIntention
  config = config || {}
  return axios.post(url, data, config)
}
// 运营获取想签主播列表
export function getWantSignActorList(config) {
  const url = '/mps/anchor/want_to_sign_list'

  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}

/**
 *
 *
 * 法务专用，获取法务一些信息
 */
export function addAgreementActor(data, config) {
  const url = '/bs/anchor/contract/save'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
// 检查身份证是否重复
export function checkIdCard(data, config) {
  const url = '/bs/anchor/contract/checkIdCard'
  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}

// 获取该合同主播信息
export function getAgreementAgentInfo(config) {
  const url = '/bs/anchor/contract/view/' + config.params.anchorId
  delete config.params.anchorId
  const opts = _.merge({}, config || {})
  return axios.get(url, opts)
}
// 修改合同主播
export function updateAgreementActor(data, config) {
  const url = '/bs/anchor/contract/update'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}

// 更改主播签约状态-签约/解约
export function changeActorContractStatus(data, config) {
  const url = '/bs/anchor/contract/updateContractStatus'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}

// 更改主播签约状态-签约/解约
export function bindAgent(data, config) {
  const url = '/bs/anchor/bind_operator'

  data = data || {}
  config = config || {}
  return axios.post(url, data, config)
}
